﻿using System;
using Zinnia.Lite.Core;
using Zinnia.Lite.Core.Imp;

namespace Zinnia.Lite.Untilty
{
    /// <summary>
    /// XML帮助类
    /// </summary>
    public sealed class XMLHelper
    {
        /// <summary>
        /// XML反序列化
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="Xml"></param>
        /// <returns></returns>
        public static T XmlDeserialize<T>(string Xml)
        {
            IXmlSerializerService xmlService = new XmlSerializerService(typeof(T));
            return (T)xmlService.XmlDeserialize(Xml);
        }
        /// <summary>
        /// XML序列化
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static string XmlSerialize<T>(T obj)
        {
            IXmlSerializerService xmlService = new XmlSerializerService(typeof(T));
            return xmlService.XmlSerialize(obj);
        }
    }
}
